package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.Lxsbm;
import cn.gson.fengboot.model.pojos.Lxsmbcb;
import cn.gson.fengboot.model.service.LxsmbService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/vue")
public class LxsmbController {
    @Autowired
    LxsmbService lxsmbService;

    /*查询部门目标总值*/
    @RequestMapping("/bumenmubiao")
    @ResponseBody
    public  Map<String,Object> bumenmubiao(Integer currentPage , Integer pageSize,Integer deptid,String shijian){
        if(currentPage==null || currentPage==' '||pageSize==null||pageSize==' '){
            currentPage=1;
            pageSize=5;
        }
        List<Lxsbm> lxsbms =lxsmbService.bumenmubiao(deptid,shijian);
        Page<Object> obj= PageHelper.startPage(currentPage, pageSize);
        Map<String,Object> map = new HashMap<>();
        map.put("row",lxsbms);
        map.put("fenye",obj.getTotal());
        return map;
    }

    /*查询部门目标总值*/
    @RequestMapping("/ygyjselect")
    @ResponseBody
    public Map<String,Object> sleectName(String date3){
        Map<String,Object> map = lxsmbService.ygyjselect(date3);
        return map;
    }


    /*查询部门目标总值*/
    @RequestMapping("/yearselect")
    @ResponseBody
    public Map<String,Object> yearselect(String date1,String date2){
        Map<String,Object> map = lxsmbService.yearselect(date1,date2);
        return map;
    }


    /*查询部门目标总值*/
    @RequestMapping("/depselect")
    @ResponseBody
    public Map<String,Object> depselect(Integer deptid){
        Map<String,Object> map = lxsmbService.depselect(deptid);
        return map;
    }


    //新增
    @RequestMapping("/AddXsmb")
    @ResponseBody
    public void AddXsmb(@RequestParam String fun){
        lxsmbService.AddXsmb(fun);
    }

    //查询员工
    @RequestMapping("/empselect")
    @ResponseBody
    public Map<String,Object> empselect(Integer deptid){
        Map<String,Object> map = lxsmbService.empselect(deptid);
        return map;
    }
}
